// HTTP请求方法枚举
export enum HttpMethod {
  GET = 'GET',
  POST = 'POST'
}

// 请求配置接口
export interface RequestConfig {
  url?: string;
  baseURL?: string;
  method?: HttpMethod;
  data?: any;
  params?: Record<string, any>;
  headers?: Record<string, string>;
  timeout?: number;
  dataType?: 'json' | 'text';
  responseType?: 'text' | 'arraybuffer';
}

// 请求拦截器接口
export interface RequestInterceptor {
  onRequest?: (config: RequestConfig) => RequestConfig | Promise<RequestConfig>;
  onRequestError?: (error: any) => any;
}

// 响应拦截器接口
export interface ResponseInterceptor {
  onResponse?: (response: any) => any;
  onResponseError?: (error: any) => any;
}

// 统一响应格式
export interface ApiResponse<T = any> {
  code: number;
  data: T;
  message: string;
}

// 自定义错误类
export class HttpError extends Error {
  constructor(
    public code: number,
    message: string,
    public data?: any
  ) {
    super(message);
    this.name = 'HttpError';
  }
} 